package com.example.yang.ministy.com.example.yang.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import com.example.yang.ministy.R;
import com.example.yang.ministy.com.example.yang.WonderMomentFragment.WonderMessageFragment;
import com.example.yang.ministy.com.example.yang.WonderMomentFragment.WonderMomentFragment_la;

/**
 * Created by Yang on 2016/9/22.
 */
public class WonderFragment extends Fragment {
    private View LayoutView;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
     LayoutView = inflater.inflate(R.layout.fragment_wonder,null);
        return LayoutView;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        RadioGroup wonderFind=(RadioGroup)LayoutView.findViewById(R.id.rg_main);
        wonderFind.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId==R.id.rb_ms){
                    showFramgment(new WonderMomentFragment_la());

                }else if (checkedId==R.id.rb_wo){
                    showFramgment(new WonderMessageFragment());
                }
            }
        });

    }
    private void showFramgment(Fragment fragment){
        FragmentTransaction fragmentTransaction=getChildFragmentManager().beginTransaction();
        fragmentTransaction.replace(R.id.flam_content,fragment);
        fragmentTransaction.commit();
    }
}
